var tips = document.getElementById("tips");
var xhr;
function showRemainInfo() {
    var content = document.getElementById('searchText').value;
    xhr = new XMLHttpRequest();
    if (content === "") {
        return 0;
    }
    else{
        xhr.onreadystatechange = process;
        xhr.open("GET", "searchProductAjax?name=" + content, true);
        xhr.send(null);
    }
}
function process(){
    var result = xhr.responseText.split(",");
    var html = "";
    for(var i=0;i < result.length;i++){
        //每个div有鼠标移出，移入事件
        html += "<option onclick = 'textOn(this)' onmouseout = 'changeBackColorOut(this)' onmouseover = 'changeBackColorOver(this)'>" + result[i] + "</option>";
    }
    tips.innerHTML = html;
}
function textOn(div) {
    document.getElementById(searchText).value(div.innerText);
    tips.style.display = "none";
}
function changeBackColorOut(div) {
    tips.style.backgroundColor = "#E0E5E5";
}
function changeBackColorOver(div) {
    tips.style.backgroundColor = "#CCCCCC";
}